//
//  YSProductDetailBottomBar.m
//  Yueshi
//
//  Created by Northwan on 15/7/23.
//  Copyright (c) 2015年 悦食中国. All rights reserved.
//

#import "YSProductDetailBottomBar.h"

@interface YSProductDetailBottomBar()

@end

@implementation YSProductDetailBottomBar


-(void)awakeFromNib{
    UIImage *cartImg = [UIImage imageNamed:@"btn_cart"];
    _cartView = [[CartView alloc]initWithImage:@"btn_cart"];
    [_cartView setX:YSPublicXInset*2];
    [_cartView setY:YSProductDetailBottomBarHeight/2 - cartImg.size.height/2-5];
    [_cartView addTarget:self action:@selector(toCartCtrl) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_cartView];
}

-(void)toCartCtrl{
    [Utils showCartCtrl:self.viewController];
}

+(instancetype)bottomBar{
    return [[[NSBundle mainBundle]loadNibNamed:@"YSProductDetailBottomBar" owner:nil options:nil]lastObject];
}

- (IBAction)tapAction:(UIButton *)sender {
    switch (sender.tag) {
        case 1:{//add cart
            if (self.addCart) {
                self.addCart();
            }
            break;
        }
        case 2:{//immediately buy
            if (self.immediateBuy) {
                self.immediateBuy();
            }
            break;
        }
        default:
            break;
    }
}

@end
